const jwt = require('jsonwebtoken');
const fs = require('fs');
const path = require('path');

const TOKEN_PRI = `-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,85646E7D32D1132CF12AFEE58CCDA7C3

D1nF82avFRrp17Oig2flIUf3pTbupgI6DoI4PazrEbdCov7HFyT7mK7XZhKttcCq
YxRgBKfPUJlbkTvAHRQnxikZ0s/L7YuKfrwHkrMeOxhcQDuCeK5ynx3TqyoteSfq
o/vwo7qiELPSQ/bMu+kvLe8mxM2e+SVGAEfZfsSTcans9WDQrDsEkeLaXvsjfXdh
JWRKlAX79febX9eunf0MNTyg8/VENfsNK3gqaIePmX3EM/BcmEUSjokTPTBqsOpq
ALXAaqgT89bHGhRiekocU6HZhLu9Dd6BVAhweby6dt0lgnSkNlAuv6lX1r7EIpyv
9TQanZBywFITSlMcVgclQSYPceB5ZcJVlDL09vlmTW/cp1FHCmUfuYoGDJRl0rSV
5rPSKaurFnFe5fjfU4yAs1L0zdUZzU/PwRULAG6YgqodYsLzvaEZF265O34/Zwuu
o7tKxhT+POWekFeWipdoDo6LmfOXYaIBgvvJQQL0IbDMo8xOBTL8zunliWH2WCHL
v3AQMOJvsQ7a4jE9e/A7HzFO/o1Hv+ej29PZsT5hlOjNUU57Z9D3aSR8Sf8cNuqy
ZNI5lunw79cI/5WUwAF6+VgqJ2z4PS5w6z6yGhNBTlGCnM4HRjrqKh4rRs0BbAI6
jLV7aUVk7KfyvBJk2P944G1liJU5/9FXC1P6AEo2YAPGen5/rZppGjCIvRW1cltU
7RVXWz9MqHKuxkisO7WS/QmrkQJBOYwCErM5iuGO2m6q4W/u7KUL+saLa1KjcQNy
DtVK1K+T68MfOn/ITDnX8eVBxH+pzLucfM/r+bVcPevCB4tGbS1De4Gnd8AgiB/I
9VH6zK8SYvKWlxOLAHwRPQtQ30xcPLuxFngiz0DbGvMAH14l9kFEdv2ynRLSEWaj
WN9e4EVYap+5tH+W5k0UFTOq0bTklRtWmELTLrCCPnnlL+KCQM0+RkB+z2svTgjR
ewB84h38lSQktcJDSM5k6XJCoqfEx0u8YwiU9R/NYP5VL1vEguOBzwGcr2dfF2R3
Wbxpabq+qcNks5Q5OnUYnHDiFLhxxiAo6t3riWMJoP4fjMnKGx387JMlhma3vzyw
0N2mLyi84H2MYXs6E7yrmpmhdTd7xPMOhWGRRWp85RQiCz2/ENG7Bh3TBKErdI8h
nyKPR+f990QqlSxMPI8slnscgshzS/qIIumtsxPPT4tnz4vSRziKnupJIkVkdoUz
hX2Ct8GpWX3+ueN1YWRC3Un6mPemHtqiUGg7lQyr37n0xICG4qffNAim7/zVFas8
zljM3OXJL4iDdaIstf0cKJ1FXRiLmtGqj3BRIJq5w8AGo7EKpe99zEfLN99XRrK8
HbZZ1WvUyhF1qJAyzDqrWljRGS1c/mcq7IKs1agRtilC31+k60MY5qb7qS8TOnB9
r922OrMDsf0+Qx4BsFQ7uex0monZOnjdhW9T+o/9n2q7oYzYebcaJvIfAy6ylNIJ
yD7CvFavSEzoqINWMrek9q6j1pVOmqqo+0OlYrhN/97QeOCadZwKBkEnM2cfmQd/
HBx3clASVKmskpegPfOpPkh6DbuV96wkWdegYN9UaU3dagnrqaBBVlw9+aNwMpPi
-----END RSA PRIVATE KEY-----`;

//生成token的方法
exports.generateToken = (data , time ) => {
	let created = Math.floor(Date.now() / 1000);

	let token = jwt.sign(
		{
			data,
			exp: created + time
		},
		TOKEN_PRI
	);
	return token;
};
